﻿@layout PersonalCenterLayout
@page "/user/base"
@inherits PersonalPageBase
<BTab Type="@TabType.Card" EnableAlwaysRender="true">
    <BTabPanel Title="@tabTitle" EnableAlwaysRender="true">
        @if (User != null)
        {
            <div class="app-user-info">
                <BForm LabelAlign="@LabelAlign.Right" @ref="userInfoForm" Value="User" EnableAlwaysRender="true">

                    <div style=" display:flex;">
                        <BFormItem TValue="string" Label="账号" Name="@nameof(BZUserModel.UserName)">
                            @User?.UserName
                        </BFormItem>
                        <BFormActionItem Style="text-align:left;margin-left:300px;" EnableAlwaysRender="true">
                            @if (Disabled)
                            {
                                <BButton Type="@ButtonType.Default" OnClick=" EditUser" IsCircle="true" IsPlain="true" Icon="el-icon-edit"></BButton>
                            }
                            else
                            {
                                <BButton Type="@ButtonType.Default" OnClick="SaveUser" IsCircle="true" IsPlain="true" Icon="el-icon-check"></BButton>
                            }
                        </BFormActionItem>
                    </div>

                    <BFormItem TValue="string" Label="昵称" Name="@nameof(BZUserModel.NickName)" Style="max-width:300px;" EnableAlwaysRender="true">
                        @if (Disabled)
                        {
                            @User?.NickName
                        }
                        else
                        {
                            <BInput TValue="string" Placeholder="输入昵称" EnableAlwaysRender="true"></BInput>
                        }
                    </BFormItem>

                    <BFormItem TValue="string" Label="邮箱" Name="@nameof(BZUserModel.Email)">

                        @(string.IsNullOrWhiteSpace(User?.Email) ? "暂未绑定邮箱" : User.Email)
                    </BFormItem>
                    <BFormItem TValue="string" Label="手机" Name="@nameof(BZUserModel.PhoneNumber)">
                        @(string.IsNullOrWhiteSpace(User?.PhoneNumber) ? "暂未绑定手机" : User.PhoneNumber)
                    </BFormItem>
                    <BFormItem TValue="int?" Label="性别" Name="@nameof(BZUserModel.Sex)" EnableAlwaysRender="true">

                        @if (Disabled)
                        {
                            <BRadio @bind-SelectedValue="User.Sex" Value="0" StatusChanging="@OnStatusChanging">男</BRadio>
                            <BRadio @bind-SelectedValue="User.Sex" Value="1" StatusChanging="@OnStatusChanging">女</BRadio>
                        }
                        else
                        {
                            <BRadio @bind-SelectedValue="User.Sex" Value="0">男</BRadio>
                            <BRadio @bind-SelectedValue="User.Sex" Value="1">女</BRadio>
                        }
                    </BFormItem>
                    @*<BFormItem TValue="string" Label="地区" Name="@nameof(BZUserModel.LastLoginAddr)" EnableAlwaysRender="true">
                        @if (Disabled)
                        {
                            @(User?.LastLoginAddr ?? "未知")
                        }
                        else
                        {
                            <BInput TValue="string" ></BInput>
                        }
                    </BFormItem>*@
                <BFormItem TValue="string" Label="签名" Name="@nameof(BZUserModel.Signature)" Style="max-width:500px;" EnableAlwaysRender="true">
                    @*@if (Disabled)
        {
            @(User?.Signature ?? "您还没有设置一个座右铭")
        }
        else
        {
            <BInput TValue="string" Type="InputType.Textarea" Placeholder="输入座右铭" EnableAlwaysRender="true"></BInput>
        }*@
                    <div style="margin-top:6px; width:800px;">
                        @if (Disabled)
                        {
                            <BMarkdown Text="@(string.IsNullOrWhiteSpace(User.Signature) ? "写点什么呗": User.Signature)"></BMarkdown>
                        }
                        else
                        {
                            <BMarkdownEditor @bind-Value="@User.Signature" UploadUrl="@(UploadUrl+ UploadPath.Avator.Description())" DisableFileUpload="true" DisableImageUpload="false" ImageMaxSize="ConstConfig.MaxUploadFileSize" Height="300"></BMarkdownEditor>
                        }
                    </div>
                    </BFormItem>

            <BFormItem TValue="string" Name="@nameof(BZUserModel.Id)" IsHidden="true">
                <BInput TValue="string"></BInput>
            </BFormItem>
            </BForm>
            </div>
        }
    </BTabPanel>
</BTab>